<?php js_validate();?>
<form id="form-validated" class="input" action="<?php echo $own_links;?>save" method="post" enctype="multipart/form-data">
		<input type="hidden" name="employee_id" id="employee_id" value="<?php echo isset($val->employee_id)?$val->employee_id:'';?>" />
		<table class="table-form">
			<tr>
				<td>Nama Lengkap</td>
				<td><input type="text" id="nama_lengkap" name="nama_lengkap" class="validate[required,length[0,50]]"size="30" value="<?php echo isset($val->employee_fullname)?$val->employee_fullname:'';?>" /></td>
			</tr>
			<tr>
				<td>Jenis Kelamin</td>
				<td>
					<select id="jenis_kelamin" name="jenis_kelamin" class="validate[required]">
						<option value="1" <?php echo (isset($val->employee_gender)&& $val->employee_gender=="1")?'selected="selected"':'';?>>Pria</option>
						<option value="0"  <?php echo (isset($val->employee_gender)&& $val->employee_gender=="0")?'selected="selected"':'';?> >Wanita</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>Tempat / Tanggal Lahir</td>
				<td><input type="text" value="<?php echo isset($val->employee_placebirth)?$val->employee_placebirth:'';?>" size="20" id="tempat_lahir" name="tempat_lahir" class="validate[required]" /> / <input type="text" size="10" id="tanggal_lahir" class="validate[required] picker" readonly="true" name="tanggal_lahir" value="<?php echo isset($val->employee_datebirth)?$val->employee_datebirth:'';?>" /></td>
			</tr>
			<tr>
				<td>Email</td>
				<td><input type="text" value="<?php echo isset($val->employee_email)?$val->employee_email:'';?>" class="validate[required,custom[email]]" name="email" id="email" size="20" /></td>
			</tr>
			<tr>
				<td>Departemen</td>
				<td>
					<select name="departemen"  id="departemen">
						<option value="">Pilih Departemen</option>
						<?php
						if(count($dept['data'])>0){
							foreach($dept['data'] as $r){
								$t = isset($val->employee_dept_id)?$val->employee_dept_id:"";
								$s = ($r->dept_id==$t)?"selected='selected'":'';
								echo "<option value='".$r->dept_id."' $s >".$r->dept_code."-".$r->dept_name."</option>";
							}
						}
						?>
					</select>
				</td>
			</tr>
			<tr>
				<td>Posisi</td>
				<td>
					<select name="posisi" id="posisi">
						<option value="">-Pilih Posisi-</option>
					</select>
				</td>
			</tr>
			<tr valign="top">
				<td>Photo</td>
				<td><input type="file" name="photo_file" id="photo_file" /><br />
				<?php if(isset($val->employee_photo) && trim($val->employee_photo)!=""){?>
				<img src="<?php echo get_image(base_url()."uploaded/employees/medium/".$val->employee_photo);?>" width="40" />
				<?php } ?>
				</td>
			</tr>
			<tr><td colspan="2">&nbsp;</td></tr>
			<tr>
				<td><input type="reset" onclick="document.location='<?php echo $own_links;?>'" class="btnbatal" value="Batal" /></td>
				<td align="right"><input type="submit" class="btnsimpan" value="Simpan" /></td>
			</tr>
		</table>
	</form>
	
<script language="javascript">
var id_posisi_db = '<?php echo isset($val->employee_position_id)?$val->employee_position_id:"";?>';
getPosition(id_posisi_db);
 $('#departemen').change(function(){
 	getPosition(id_posisi_db);
 });
 
function getPosition(q){
	html = "<option value=''>- pilih posisi -</option>";
	$.post(SELF_URL+"get_position",{
			dept_id : $('#departemen').val()
		},function(o){
			m = eval("("+o+")");
			if(m.length > 0){
				for(j=0;j<m.length;j++){
					s = (m[j].position_id==q)?"selected='selected'":"";
					html +="<option value='"+m[j].position_id+"' "+s+">"+m[j].position_desc+"</option>";
				}
			}
			$('#posisi').html(html);
			
	});
	
}
</script>